<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=640px,user-scalable=no,target-densitydpi=device-dpi" />
		<link rel="stylesheet" href="../css/css.css" type="text/css" />
		<script type="text/javascript" src='../js/jquery.min.js'></script>
		<script type="text/javascript" src='../js/main_in.js'></script>
		<script type="text/javascript" src='../js/common.js'></script>
		<script type="text/javascript" src='../js/mui.min.js'></script>
		<title>主页</title>
		<script>
			/*$(function(){
				$('body').on('click','.bg_submit',function(){
					$('#etc_type').show();
				});
			});*/
			var qw = 1;
			var uid = window.localStorage["uid"];
			$(function(){
				
				do_search()
				$("body").on('click', ".bgsearch_main", function() {
                    if(qw == 1){
                        $(this).find(".disnone").show();
                        $(this).css("background","#279EEE");
                        $(this).css("color","#fff");
                        $(this).find(".bgsearch_main_hang").css("border-bottom","1px solid #fff");
                        qw = 2;
                    } else{
                        $(".bgsearch_main").find(".disnone").hide();
                        $(".bgsearch_main").css("background","#fff");
                        $(".bgsearch_main").css("color","#BCBCBC");
                        $(".bgsearch_main").find(".bgsearch_main_hang").css("border-bottom","1px solid #BCBCBC");
                        qw = 1;
                    }
                    
                });
                
                $("body").on('click', ".express_search", function() {
                    var no = $(this).parent().parent().find('.express_val').html();
                    if(no != ''){
                    	clicked('express.html?no=' + no);
                    }else{
                    	alert("快递尚未寄出")
                    }
                });
			})
			function do_search(){
				var type = {
					0 : '申请失败',
					1 : '审核中',
					2 : '制卡中',
					3 : '派送中',
					4 : '申请完成'
				}
                $.ajax({
                    url: "http://insure.unair.cn/etcsearch.php",
                    type: "POST",
                    data: {
                    	"uid" : uid
                    },
                    success: function(data) {
                          data = eval("(" + data + ")");

                        var item = '';
                        if(data != null){
                        	$.each(data, function(k, v) {
	                            v.etccard = typeof (v.etccard) == 'undefined' ? '' : v.etccard;
	                            v.etccard = v.etccard == null ? '' : v.etccard;
	                            v.express = typeof (v.express) == 'undefined' ? '' : v.express;
	                            v.express = v.express == null ? '' : v.express;
	                            v.address = typeof (v.address) == 'undefined' ? '' : v.address;
	                            v.address = v.address == null ? '' : v.address;
	                            v.remark = typeof (v.remark) == 'undefined' ? '' : v.remark;
	                            v.remark = v.remark == null ? '' : v.remark;
	                            
								var timestamp1 = Date.parse(new Date(v.createtime.date));
								var d = new Date(timestamp1);
								var time = '';
								time += d.getFullYear() + '-';
								time += d.getMonth() + 1 + '-';
								time += d.getDate() + '';
								time += ' ';
								time += d.getHours() + ':';
								time += d.getMinutes() + ':';
								time += d.getSeconds() + ''
								var eid = v.id * 1 + 10000;
								if(v.isrefund == 0 || v.isrefund == undefined || v.isrefund == null){
									state = type[v.type];
								}
								if(v.isrefund == 1 ){
									state = '退款中';
								}
								if(v.isrefund == 2 ){
									state = '退款完成';
								}
								
					                            
	                           item += '<div class="bgsearch_main">' +
	                           				'<div class="bgsearch_main_hang">' +
	                                            '<div class="bgsearch_main_left">编号:</div>' +
	                                            '<div class="bgsearch_main_right">' + eid + '</div>' +
	                                        '</div>' +
	                                        '<div class="bgsearch_main_hang">' +
	                                            '<div class="bgsearch_main_left">状态:</div>' +
	                                            '<div class="bgsearch_main_right">' + state + '</div>' +
	                                        '</div>' +
	                                        '<div class="bgsearch_main_hang">' +
	                                            '<div class="bgsearch_main_left">ETC卡号:</div>' +
	                                            '<div class="bgsearch_main_right">' + v.etccard + '</div>' +
	                                        '</div>' +
	                                        '<div class="bgsearch_main_hang">' +
	                                            '<div class="bgsearch_main_left">申请时间:</div>' +
	                                            '<div class="bgsearch_main_right">' + time + '</div>' +
	                                        '</div>' +
	                                        '<div class="bgsearch_main_hang disnone">' +
	                                            '<div class="bgsearch_main_left">地址:</div>' +
	                                            '<div class="bgsearch_main_right">' + v.address + '</div>' +
	                                        '</div>' +
	                                        '<div class="bgsearch_main_hang disnone">' +
	                                            '<div class="bgsearch_main_left">备注:</div>' +
	                                            '<div class="bgsearch_main_right">' + v.remark + '</div>' +
	                                        '</div>' +
	                                        '<div class="bgsearch_main_hang disnone">' +
	                                            '<div class="bgsearch_main_left">快递单号:</div>' +
	                                            '<div class="bgsearch_main_right express_val">' + v.express + '</div>' +
	                                        '</div>' +
	                                        '<div class="bgsearch_main_hang disnone">' +
	                                            '<div class="bgsearch_main_left">&nbsp;</div>' +
	                                            '<div  class="bgsearch_main_right express_search">点此物流查询</div>' +
	                                        '</div>' +
	                                        
	                                '</div>';
	                        });
	                        $('.search_body').append(item);
                        }
	                        
                    },
                    error: function(data) {
//                        alert("刷新失败")
                    }
                });
			}
			
			
			
				
		</script>
	</head>
	<body>
		
		<div class="app_head">
            <div class="app_prev" onclick="clicked('../index.html')"><img src="../img/arrow.png" /></div>
            <div class="app_head_text">申请查询</div>
            <div class="app_prev"></div>
        </div>
        <div class="app_body">
        	<div style="background: #fff;width: 100%;height: 100px;">
				<div class="bg_submit" onclick="clicked('./etc_type.html')">申&nbsp;请</div>
				<div class="bg_back_class" onclick="clicked('../index.html')">返&nbsp;回</div>
			</div>
		
			<div class="main_in_input" id="etc_type" style="display:none;">
              
            </div>
			
        </div>
        
        <div class="search_body"></div>
        

	</body>
</html>
